package com.yycx.module.bus.provider.service;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.model.ResultBody;
import com.yycx.module.bus.client.entity.BusCustomBalance;
import com.yycx.common.mybatis.base.service.IBaseService;
import com.yycx.module.bus.client.entity.BusPayment;
import com.yycx.module.bus.client.entity.hy.HyOrder;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 客户账户收支记录 接口
 *
 * @author flyme
 * @date 2023-08-22
 */
public interface BusCustomBalanceService extends IBaseService<BusCustomBalance> {

    /**
     * 根据订单ID查询
     *
     * @param orderId
     * @return
     */
    List<BusCustomBalance> selectListByOrderId(Serializable orderId);


    /**
     * 根据订单ID删除
     *
     * @param orderId
     * @return
     */
    boolean removeByOrderId(Serializable orderId);

    /**
     * 删除货款抵扣并更新账户余额
     *
     * @param orderId
     */
    void updateCustomBalance(Serializable orderId);


    /**
     * 拆分金额
     *
     * @param customBalanceId
     * @param amount
     * @param orderId
     * @param orderDetailsId
     * @return
     */
    BusCustomBalance cfAmount(Long customBalanceId, BigDecimal amount, String orderId, String orderDetailsId);

    /**
     * 拆分账户
     *
     * @param customBalanceId
     * @param amount
     * @return
     */
    BusCustomBalance cfAmount(Long customBalanceId, BigDecimal amount);

    /**
     * 撤销余额和订单的关联
     *
     * @param customBalanceId
     * @return
     */
    Boolean revokeOrderDetailsUse(Long customBalanceId);


    /**
     * 撤销拆分
     *
     * @param customBalanceId
     * @return
     */
    ResultBody revokeCfAmount(Long customBalanceId);



    /**
     * 更新拆分金额
     *
     * @param customBalanceId
     * @param amount
     */
    void updateCfAmount(Long customBalanceId, BigDecimal amount);


    /**
     * 查询货款余额记录
     *
     * @param customId
     * @param companyId
     * @return
     */
    BusCustomBalance findByCustomId(Long customId, Long companyId);


    /**
     * 统计退货款信息
     *
     * @param selectIds
     * @return
     */
    EntityMap totalReturnAmountInfo(String selectIds);

    /**
     * 关联退款申请ID
     *
     * @param paymentId
     * @param settleIds
     * @return
     */
    Boolean updateRefundId(Long paymentId, String settleIds);


    /***
     * 清空退货款申请ID
     * @param refundId
     * @return
     */
    Boolean clearRefundId(Serializable refundId);

    /**
     * 更新退款信息为已退款
     *
     * @param payment
     * @return
     */
    Boolean updateRefundInfo(BusPayment payment);


    /**
     * 查询货款余额账户
     *
     * @param customCode
     * @param companyId
     * @return
     */
    BusCustomBalance findByCustomCode(String customCode, Long companyId);


    /**
     * 保存货款余额
     *
     * @param customCode
     * @param companyId
     * @param orderId
     * @param amount
     */
    void saveHkCustomBalance(String customCode, Long companyId, String orderId, BigDecimal amount);

    /**
     * 保存货款余额
     *
     * @param customId
     * @param amount
     */
    void saveHkCustomBalance(Long customId, BigDecimal amount);

}
